using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Globalization;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Shc.Csharp.Administrativo.Ad
{
    public sealed class TipoLogradouro
    {
        /// <summary>
        /// Pesquisa Logradouros.
        /// </summary>
        /// <returns>DataSet</returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [awilliam]	19/08/2008 16:45:00	Created
        /// </history>
        public static DataSet PesquisaTipoLogradouro(int iTipRegist, string sDescLogr,  int tamanhoPagina, int numeroPagina, out int totalRegistros)
        {
            Database myDatabase = DatabaseFactory.CreateDatabase();
            DbCommand myCommand = myDatabase.GetStoredProcCommand("dbo.spPesquisarTiposLogradouro");

            totalRegistros = 0;
            myDatabase.AddInParameter(myCommand, "@TipReg", DbType.Int32, iTipRegist);
            myDatabase.AddInParameter(myCommand, "@DescLogr", DbType.String, sDescLogr);
            myDatabase.AddInParameter(myCommand, "@TamanhoPagina", DbType.Int32, tamanhoPagina);
            myDatabase.AddInParameter(myCommand, "@NumeroPagina", DbType.Int32, numeroPagina);
            myDatabase.AddOutParameter(myCommand, "@TotalRegistros", DbType.Int32, totalRegistros);

            DataSet ds = myDatabase.ExecuteDataSet(myCommand);
            totalRegistros = int.Parse(myDatabase.GetParameterValue(myCommand, "@TotalRegistros").ToString());
            return ds;
        }

        /// <summary>
        /// incluir Logradouros.
        /// </summary>
        /// <returns>DataSet</returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [awilliam]	19/08/2008 16:45:00	Created
        /// </history>
        public static DataSet IncluirLogradouro(int iCodLogr, int iTipRegist, string sLogradouro, string sAbrevLogr, string sDscLogrAlter, string sglSistema, int iCodUsuario)
        {
            Database myDatabase = DatabaseFactory.CreateDatabase();
            DbCommand myCommand = myDatabase.GetStoredProcCommand("dbo.spCadastraNovoTipoLogradouro");

            myDatabase.AddInParameter(myCommand, "@CodLogr", DbType.Int32, iCodLogr);
            myDatabase.AddInParameter(myCommand, "@TipRegLogr", DbType.Int32, iTipRegist);
            myDatabase.AddInParameter(myCommand, "@DscLogr", DbType.String, sLogradouro);
            myDatabase.AddInParameter(myCommand, "@AbvLogr", DbType.String, sAbrevLogr);
            myDatabase.AddInParameter(myCommand, "@DscLogrAlter", DbType.String, sDscLogrAlter);
            myDatabase.AddInParameter(myCommand, "@SglSistAtz", DbType.String, sglSistema);
            myDatabase.AddInParameter(myCommand, "@CodUsuAtz", DbType.Int32, iCodUsuario);

            DataSet ds = myDatabase.ExecuteDataSet(myCommand);
            return ds;

        }

        /// <summary>
        /// Pesquisa Logradouros Alternativos de De-Para.
        /// </summary>
        /// <returns>DataSet</returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [awilliam]	19/08/2008 16:45:00	Created
        /// </history>
        public static DataSet PesquisaLogradouroAlternativos(string  sLogradouro)
        {
            Database myDatabase = DatabaseFactory.CreateDatabase();
            DbCommand myCommand = myDatabase.GetStoredProcCommand("dbo.spPesquisarTiposLogradouroAlternativos");

            myDatabase.AddInParameter(myCommand, "@Logradouro", DbType.String, sLogradouro);

            DataSet ds = myDatabase.ExecuteDataSet(myCommand);
            return ds;
        }
    }
}
